from django.http.response import JsonResponse
from django.views import View
from django.views.decorators.csrf import csrf_exempt


def hello(request, *args, **kwargs):
    print(1111)
    return JsonResponse({'message': 'Hello World!'})


class TestView(View):

    def get(self, request, *args, **kwargs):
        print(self)
        print(request)
        return JsonResponse({'message': 'Class View get Hello World!'})

    def post(self, request, *args, **kwargs):
        print(self)
        print(request)
        return JsonResponse({'message': 'Class View post Hello World!'})

    def put(self, request, *args, **kwargs):
        print(self)
        print(request)
        return JsonResponse({'message': 'Class View put Hello World!'})

    def delete(self, request, *args, **kwargs):
        print(self)
        print(request)
        return JsonResponse({'message': 'Class View delete Hello World!'})

    @csrf_exempt
    def dispatch(self, request, *args, **kwargs):
        return super().dispatch(request, *args, **kwargs)
